﻿using Max.PH5_2004A.Shopping.Domain;
using Max.PH5_2004A.Shopping.DAL;
using Max.PH5_2004A.Shopping.IRespository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Max.PH5_2004A.Shopping.Respository
{
    public class MemberRespository : CRUDRespository<MemberModel>, IMemberRespository
    {

        //通过构造函数从IOC容器中获取到了上下文件对象
        public MemberRespository(MaxPH52004AShoppingDbContext context) : base(context)
        {
            _context = context;
        }

        //额外需要处理登录，需要用到上下文对象
        //所以我们定义一个上下文件对象
        MaxPH52004AShoppingDbContext _context;


        //然后通过构造函数中的对象赋值获取


        public int Login(MemberModel model)
        {
            var m = _context.Members.Where(x => x.Name.Equals(model.Name)).FirstOrDefault();
            if (m == null)
                return -1;

            return 1;
        }
    }
}
